<%@ page import="com.bw.pojo.Customer" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: Aaking-aline
  Date: 2022-05-07
  Time: 14:31
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head>
    <title>信息展示首页</title>

    <style>
      table,th,tr,td{
        border: aquamarine 3px solid;
      }
    </style>

  </head>
  <body>
    <center>
      <table>
        <tr>
          <td>ID</td>
          <td>name</td>
          <td>age</td>
          <td>address</td>
          <td>delete</td>
          <td>update</td>
        </tr>


        <%
          List<Customer> list = (List<Customer>)request.getAttribute("list");  // index.jsp第一次加载的时候 获取不到这个集合

          if(list == null){
            response.sendRedirect("SelectAllServlet");
            return ;
          }

          for (Customer cus : list) {  %>
            <tr>
              <td><%=cus.getId()%></td>
              <td><%=cus.getName()%></td>
              <td><%=cus.getAge()%></td>
              <td><%=cus.getAddress()%></td>
              <td><input type="button" value="删除" onclick="deleteElem(<%=cus.getId()%>)"></td>
              <td>update</td>
            </tr>
        <%} %>






      </table>
    </center>

    <script>
      function deleteElem(id){
        window.location.href = "DeleteServlet?id=" + id;
      }
    </script>

  </body>
</html>
